﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MusicExplorer.Data;
using MusicExplorer.WebRepository;
using MusicExplorer.WebRepository.Service;
using MusicExplorer.Wrappers;
using MusicExplorer.Internals;

namespace MusicExplorer.ViewModel.Popup
{
    public sealed class GroupPreferencesViewModel : EntityPreferencesViewModel
    {
        public GroupPreferencesViewModel(MainWindowViewModel parent, WebRepositoryBase webRepository)
            : base(parent)
        {
            var allGroups = ServiceWebRepository.GetGroupsFromWebRepository(webRepository.WebRepository);

            foreach (var g in allGroups.Where(g => g.group_visibility).OrderBy(g => g.group_order).Select(g => new DetailTreeItemWrapper(g))) m_enableEntities.Add(g);
            foreach (var g in allGroups.Where(g => !g.group_visibility).OrderBy(g => g.group_order).Select(g => new DetailTreeItemWrapper(g))) m_disableEntities.Add(g);
        }

        public override string EntityName { get { return "Group"; } }

        public override string EntityPluralName { get { return "Groups"; } }

        public override bool CanAddEntity { get { return false; } }

        protected override bool SearchEntityFromTerms()
        {
            // Group can't be searched
            throw new NotImplementedException();
        }
    }
}
